package com.ptszyxx.popose.module.main.mine.adapter;

import android.view.View;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseDataBindingHolder;
import com.ptszyxx.popose.R;
import com.ptszyxx.popose.databinding.ItemMineInviteRankBinding;
import com.ptszyxx.popose.module.main.mine.vm.MineInviteVM;
import com.ysg.http.data.entity.mine.InviteRankEntity;

public class MineInviteRankAdapter extends BaseQuickAdapter<InviteRankEntity, BaseDataBindingHolder<ItemMineInviteRankBinding>> {

    private MineInviteVM viewModel;

    public MineInviteRankAdapter(MineInviteVM viewModel) {
        super(R.layout.item_mine_invite_rank);
        this.viewModel = viewModel;
    }

    @Override
    protected void convert(BaseDataBindingHolder<ItemMineInviteRankBinding> holder, InviteRankEntity item) {
        ItemMineInviteRankBinding binding = holder.getDataBinding();
        if (binding != null) {
            binding.setPosition(holder.getBindingAdapterPosition() + 1);
            binding.setEntity(item);
            binding.executePendingBindings();

            int position = holder.getBindingAdapterPosition();
            if (position == 0) {
                binding.ivRank.setVisibility(View.VISIBLE);
                binding.tvNumber.setVisibility(View.GONE);
                binding.ivRank.setImageResource(R.mipmap.invite_rank1);
            } else if (position == 1) {
                binding.ivRank.setVisibility(View.VISIBLE);
                binding.tvNumber.setVisibility(View.GONE);
                binding.ivRank.setImageResource(R.mipmap.invite_rank2);
            } else if (position == 2) {
                binding.ivRank.setVisibility(View.VISIBLE);
                binding.tvNumber.setVisibility(View.GONE);
                binding.ivRank.setImageResource(R.mipmap.invite_rank3);
            } else {
                binding.ivRank.setVisibility(View.GONE);
                binding.tvNumber.setVisibility(View.VISIBLE);
                binding.tvNumber.setText((position + 1) + "");
            }
        }
    }








}
